package com.bonc.excel.configuration;

import com.bonc.excel.biz.ExcelFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author: wujing
 * @Date: 2024/9/4 14:58
 * @Description: TODO
 **/
@Slf4j
@Component
public class ScheduleTask implements InitializingBean, DisposableBean {

    @Resource
    private ExcelFactory excelFactory;

    @Override
    public void afterPropertiesSet() throws Exception {
        log.info("afterPropertiesSet ...");


       // JobLogReportHelper.getInstance().start();
   /*     Executors.newScheduledThreadPool(1).scheduleWithFixedDelay(() -> {
            try {
                log.info("newScheduledThreadPool ...");
                screenFactory.getCommonData();
             //   log.info("getcache:{}",JSONObject.toJSONString(DataContextHolder.get()));
            } catch (Exception e) {
               log.error("afterPropertiesSet error",e);
            }finally {
                log.info(" DataContextHolder.clear()");
                if(DataContextHolder.get()!=null){
                    DataContextHolder.clear();
                }
               // log.info(" DataContextHolder.clear():{}", JSONObject.toJSONString(DataContextHolder.get()));
            }
        }, 2, 600, TimeUnit.SECONDS);*/
    }

    @Override
    public void destroy() throws Exception {
     //   JobLogReportHelper.getInstance().toStop();
    }
}
